package com.bawei.lookfor2204a.view.fragment.zhibo

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.bawei.lookfor2204a.model.CheckVerifiedBean
import com.bawei.lookfor2204a.model.HttpUtils
import com.bawei.lookfor2204a.model.OpenLiveBean
import com.bawei.lookfor2204a.model.VideoFilterBean
import com.ksyun.media.streamer.filter.imgtex.ImgBeautySpecialEffectsFilter
import com.ksyun.media.streamer.filter.imgtex.ImgTexFilterMgt
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MultipartBody

/**
 * 作者：赵亮
 * 时间：2024/10/21 14:19
 * 功能：直播的View Model
 */
class ZhiBoViewModel : ViewModel() {

    // 美颜数据
    val meiYanList = listOf(
        VideoFilterBean("禁用美颜", ImgTexFilterMgt.KSY_FILTER_BEAUTY_DISABLE),
        VideoFilterBean("自然", ImgTexFilterMgt.KSY_FILTER_BEAUTY_DENOISE),
        VideoFilterBean("白肤", ImgTexFilterMgt.KSY_FILTER_BEAUTY_SKINWHITEN),
        VideoFilterBean("嫩肤", ImgTexFilterMgt.KSY_FILTER_BEAUTY_SOFT),
        VideoFilterBean("简单", ImgTexFilterMgt.KSY_FILTER_BEAUTY_SOFT_SHARPEN),
        VideoFilterBean("轻度嫩肤", ImgTexFilterMgt.KSY_FILTER_BEAUTY_SOFT_EXT),
        VideoFilterBean("柔肤", ImgTexFilterMgt.KSY_FILTER_BEAUTY_ILLUSION),
        VideoFilterBean("粉嫩", ImgTexFilterMgt.KSY_FILTER_BEAUTY_PRO),
        VideoFilterBean("白皙", ImgTexFilterMgt.KSY_FILTER_BEAUTY_SMOOTH),
    )
    // 滤镜数据
    val lvJingList = listOf(
        VideoFilterBean("小清新", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_FRESHY),
        VideoFilterBean("青春靓丽", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_BEAUTY),
        VideoFilterBean("甜美可人", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_SWEETY),
        VideoFilterBean("怀旧", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_SEPIA),
        VideoFilterBean("蓝调", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_BLUE),
        VideoFilterBean("老照片", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_NOSTALGIA),
        VideoFilterBean("樱花", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_SAKURA),
        VideoFilterBean("樱花（光线较暗）", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_SAKURA_NIGHT),
        VideoFilterBean("红润（光线较暗）", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_RUDDY_NIGHT),
        VideoFilterBean("红润（光线较暗）", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_SUNSHINE_NIGHT),
        VideoFilterBean("红润", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_RUDDY),
        VideoFilterBean("阳光", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_SUSHINE),
        VideoFilterBean("自然", ImgBeautySpecialEffectsFilter.KSY_SPECIAL_EFFECT_NATURE),
    )

    // 申请开启直播（主播）
    val openLiveSuccess = MutableLiveData<OpenLiveBean>()
    fun openLive(
        liveType: Int,
        liveTitle: String,
        longitude: String,
        latitude: String,
        part: MultipartBody.Part
    ) {
        HttpUtils.HttpUtils.apiService.openLive(liveType, liveTitle, longitude, latitude, part)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe { openLiveSuccess.postValue(it) }
    }

    // 检测实名认证
    val checkVerifiedSuccess = MutableLiveData<CheckVerifiedBean>()
    fun checkVerified() {
        HttpUtils.HttpUtils.apiService.checkVerified()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe { checkVerifiedSuccess.postValue(it) }
    }
}